var currentPmId="";
$(function(){
	//adaptive();
	$(".spare-al li").each(function(index){
		$(this).click(function(){
			$(".spare-al li").removeClass("active");
			$(this).addClass("active");
		});
	});
	$(".chapters .clearfix li").each(function(index){
		$(this).click(function(){
			$(".chapters li").removeClass("active chaptersAdd");
			$(this).addClass("active chaptersAdd");
		});
	});
	$(".spare-al li:first").click(); //进入页面默认选第一个
	
});
/**点击一级PM
*/
function clickFirstPm(id){
	var htmlStr="";
	$.ajax({
		type:"POST",
		url:'/tree/getPmFirstLevel?id='+id,
		 success: function (data) {
			 $("#secPmList").html("");
			 var length=data.items.length;
			 for(var i=0;i<length;i++){
				 htmlStr+="<li><a rowId=\""+data.items[i].id+"\" onclick=\"clickSecPm(this)\">"+data.items[i].title+"</a></li>";
			 }
			 $("#secPmList").html(htmlStr);
			 //$("#secPmList a:first").click(); //进入页面默认选第一个
		 }
	});
}
/**
 * 查询
 */
function searchDm(){
	$("#allDmList").html("");
	var params={size:6,title:$("#search").val(),id:currentPmId};
	loadDataPageIetm("/tree/getAllDm", "srcoll-documentation", "allDmList",params);
}
/**点击一级PM
*/
function clickSecPm(e){
	var aa=$(e);
	currentPmId=aa.attr('rowId');
	$("#secPmList a").removeClass("active chaptersAdd");
	aa.addClass("active chaptersAdd");
	$("#allDmList").html("");
	var params={size:6,id:currentPmId};
	loadDataPageIetm("/tree/getAllDm", "srcoll-documentation", "allDmList",params);
}
//分页查询，对结果的处理
function dataKk(data, me) {
	data=data.rows;
	var result = '';
	var arrLen = data.length;
	if (arrLen > 0) {
		for (var i = 0; i < arrLen; i++) {
			result+='<div class="questionsba-lista chapter-c clearfix" onclick="clickDm(this)" id="'+data[i].id+'"><div class="chapter-ca clearfix">'
				+'<div class="questionsbb-listl">数据模块代码：'+data[i].dmCode+'</div>'
				+'<div class="questionsbb-listl">标题：'+data[i].title+'</div></div>'
			+'<div class="chapter-cb">版本号：'+data[i].verNo+'<span>版本类型：'+data[i].verType+'</span>'
			+'</div><div class="documentation-check"></div></div>';
		}
	} else {
		me.lock();
		me.noData();
	}
	return result;
}
/**点击DM
*/
function clickDm(e){
	//$(".questionsba-lista").click(function() {
        $(e).toggleClass("active");
    //});
}
